<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--<!DOCTYPE html>-->
<html xmlns:ng="http://angularjs.org" id="ng-app" ng-app="ubang">
<head>
    <!--[if lte IE 8]>
    <script>
        document.createElement('ng-include');
        document.createElement('ng-pluralize');
        document.createElement('ng-view');

        // Optionally these for CSS
        document.createElement('ng:include');
        document.createElement('ng:pluralize');
        document.createElement('ng:view');
    </script>
    <![endif]-->
    <title></title>
    <meta charset="utf-8">
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <!-- 响应式设计 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link href="/res/plugin/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="/res/plugin/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="/res/plugin/jquery-validation-1.11.1/css/valid.css" rel="stylesheet">
    <link href="../res/css/main.css" rel="stylesheet">
</head>
<body>

<div class="u_child_box">
    <div class="u_title_bar">
        <span class="u_title">后台管理密码修改</span>
    </div>

    <form id="pwdForm" name="pwdForm">
        <table class="u_table u_personal u_password-box">
            <tr>
                <td class="u_contrl-bar u_align-center">

                    <div class="u_input-text-group">
                        <span class="u_label"> 输入原始密码：</span>
                        <input type="password" name="passwordOld" id="passwordOld"/>
                    </div>
                    <div class="u_input-text-group">
                        <span class="u_label"> 输入新密码：</span>
                        <input type="password" name="password" id="password"/>
                    </div>
                    <div class="u_input-text-group">
                        <span class="u_label"> 再次输入新密码：</span>
                        <input type="password" id="passwordRe"/>
                    </div>

                </td>
            </tr>
            <tr>
                <td class="u_contrl-bar">
                    <input style="width: 90px;" class="btn u_c_btn" type="button" onclick="updatePassword();" value="确认"/>
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>

<script src="/res/plugin/jquery/jquery-1.10.1.js"></script>
<script src="/res/plugin/jquery-validation-1.11.1/jquery.validate.min.js"></script>
<script src="/res/plugin/bootstrap/js/bootstrap.js"></script>
<script src="/res/plugin/angular/angular.min.js"></script>
<script type="text/javascript" src="/res/plugin/json2.js"></script>
<script src="../../res/js/common.js"></script>
<script src="../res/js/i_common.js"></script>

<script>

    window.updatePasswordUrl = window._config.url_user + "/updatePassword";

    //保存or新增联系人
    function updatePassword() {
        var ss = "0";
        //对输入数据进行验证
        var passwordOld = $("#passwordOld").val();
        if(passwordOld==""){$("#passwordOld").attr("placeholder","请输入原密码");ss = "1";}
        var password = $("#password").val();
        if(password==""){$("#password").attr("placeholder","输入密码");ss = "1";}
        var passwordRe = $("#passwordRe").val();
        if(passwordRe==""){$("#passwordRe").attr("placeholder","输入确认密码");ss = "1";}
        if(password!=passwordRe){$("#passwordRe").val("");$("#passwordRe").attr("placeholder","两次密码不一致");ss = "1";}
        if(ss=="1"){
          return;
        }else{
            //提交数据
            $.ajax({
                type: "POST",
                url: updatePasswordUrl,
                dataType: "json",
                data: "{'passwordOld':'"+passwordOld+"','password':'"+password+"'}",
                success: function(data){
                    var rmsg = data.msg;
                    if(rmsg=="ok"){
                        $("#passwordOld").val("");
                        $("#password").val("");
                        $("#passwordRe").val("");
                        alert("密码修改成功");
                    } else{
                        $("#passwordOld").val("");
                        $("#passwordOld").attr("placeholder","请输入原密码");
                        alert(rmsg);
                    }
                }
            });
        }
    }

</script>